#include"share_test.h"
#define PATHNAME "."
#define PROJ_ID 0x6666

int main()
{
    
    int fd = open("name_pipe", O_RDWR | O_APPEND);
    if (fd < 0) perror("open name_pipe fail"), exit(0);

    key_t _key = ftok(PATHNAME, PROJ_ID);
    if (_key < 0) perror("get key fail"), exit(0);

    int shmid  = shmget(_key, 4096, IPC_CREAT);
    if (shmid < 0) perror("shmget fail"), exit(0);

    char *start = (char*)shmat(shmid, NULL, 0);

    sleep(3);

    for (int i = 0; i < 26; i++ ){
        start[i] = 'A'+i;
        char buff[4] = "ok";
        write(fd, buff, sizeof(buff));
        sleep(1);
    }
    
    close(fd);
    shmdt(start);
    sleep(2);
    return 0;
}